<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:x="http://xpert.com/faces"
                 xmlns:custom="http://java.sun.com/jsf/composite/components"
                 >
    <h:form>
        <x:modalMessages/>
        <p:tabView>
            <p:tab title="#{msg['dadosGerais']}">
                <div class="container-fluid">
                    <div class="row">
                        <div class="form-group col-lg-6 col-md-12 col-sm-12 col-xs-12">
                            <h:outputLabel value="* #{msg['perfil.descricao']}:" />
                            <p:inputText value="#{perfilMB.entity.descricao}" maxlength="255"  styleClass="form-control"   />
                        </div>

                        <div class="form-group col-lg-12 col-md-12 col-sm-6 col-xs-12">
                            <div class="checkbox">
                                <label>
                                    <h:selectBooleanCheckbox value="#{perfilMB.entity.ativo}" />
                                    #{msg['perfil.ativo']}
                                </label>
                            </div>
                        </div>
                    </div>
                </div>

            </p:tab>
            <p:tab title="#{msg['acessosDoPerfil']}">
                <p:tree value="#{perfilMB.permissoes}" var="permissao"
                        selectionMode="checkbox"  
                        selection="#{perfilMB.permissoesSelecionadas}">  
                    <p:treeNode>  
                        <h:outputText value="#{permissao.descricao}" />  
                    </p:treeNode>  
                </p:tree>  
            </p:tab>
            <p:tab title="#{msg['perfil.permissoesMenu']}" rendered="#{not empty perfilMB.entity.id}">
                <div style="max-height: 500px; overflow-y: scroll;">
                    <p:tree value="#{perfilMB.permissoesMenu}" var="permissao"
                            selectionMode="checkbox"  
                            selection="#{perfilMB.permissoesSelecionadasMenu}">  
                        <p:treeNode>  
                            <h:outputText value="#{permissao.descricao}" />  
                        </p:treeNode>  
                    </p:tree>  
                </div>
            </p:tab>

        </p:tabView>
        <h:outputText value="#{xmsg['requiredFieldsForm']}"/>
        <div style="text-align: center;">
            <x:securityArea rolesAllowed="perfil.create">
                <p:commandButton process="@form" update="@form" action="#{perfilMB.save}" value="#{xmsg['save']}" />
            </x:securityArea>
            <x:securityArea rolesAllowed="perfil.audit">
                <x:audit for="#{perfilMB.entity}"/>
            </x:securityArea>
        </div>
    </h:form>
</ui:composition>